package lion.dev.image.format;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

import javax.swing.ImageIcon;

import lion.dev.image.FileFormatWriter;

public class FileFormatSER extends FileFormatWriter {

	public FileFormatSER() {
		super("Swing ImageIcon", "image/x-serialized-object", ".ser");
	}

	@Override
	public void writeImage(OutputStream out, BufferedImage image) throws IOException {

		ImageIcon icon = new ImageIcon(image);
		ObjectOutputStream oos = new ObjectOutputStream(out);
		oos.writeObject(icon);
		oos.close();
	}
}
